<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD><TITLE>Tk_Init manual page - Tk Library Procedures</TITLE>
<link rel="stylesheet" href="../docs.css" type="text/css" media="all">
</HEAD>
<BODY><H2><a href="../contents.htm">Tcl8.6.11/Tk8.6.11 Documentation</a> <small>&gt;</small> <a href="contents.htm">Tk C API</a> <small>&gt;</small> Tk_Init</H2>
<H3><A HREF="../UserCmd/contents.htm">Tcl/Tk Applications</A> | <A HREF="../TclCmd/contents.htm">Tcl Commands</A> | <A HREF="../TkCmd/contents.htm">Tk Commands</A> | <A HREF="../ItclCmd/contents.htm">[incr Tcl] Package Commands</A> | <A HREF="../SqliteCmd/contents.htm">SQLite3 Package Commands</A> | <A HREF="../TdbcCmd/contents.htm">TDBC Package Commands</A> | <A HREF="../TdbcmysqlCmd/contents.htm">tdbc::mysql Package Commands</A> | <A HREF="../TdbcodbcCmd/contents.htm">tdbc::odbc Package Commands</A> | <A HREF="../TdbcpostgresCmd/contents.htm">tdbc::postgres Package Commands</A> | <A HREF="../TdbcsqliteCmd/contents.htm">tdbc::sqlite3 Package Commands</A> | <A HREF="../ThreadCmd/contents.htm">Thread Package Commands</A> | <A HREF="../TclLib/contents.htm">Tcl C API</A> | <A HREF="../TkLib/contents.htm">Tk C API</A> | <A HREF="../ItclLib/contents.htm">[incr Tcl] Package C API</A> | <A HREF="../TdbcLib/contents.htm">TDBC Package C API</A></H3>
<DL>
<DD><A HREF="Tk_Init.htm#M2" NAME="L606">NAME</A>
<DL><DD>Tk_Init, Tk_SafeInit &mdash; add Tk to an interpreter and make a new Tk application.</DD></DL>
<DD><A HREF="Tk_Init.htm#M3" NAME="L607">SYNOPSIS</A>
<DL>
<DD><B>#include &lt;tk.h&gt;</B>
<DD>int
<DD><B>Tk_Init</B>(<I>interp</I>)
<DD>int
<DD><B>Tk_SafeInit</B>(<I>interp</I>)
</DL>
<DD><A HREF="Tk_Init.htm#M4" NAME="L608">ARGUMENTS</A>
<DL class="arguments">
</DL>
<DD><A HREF="Tk_Init.htm#M5" NAME="L609">DESCRIPTION</A>
<DL class="description">
<DD><A HREF="Tk_Init.htm#M6" NAME="L610"><B>bell</B></A>
<DD><A HREF="Tk_Init.htm#M7" NAME="L611"><B>clipboard</B></A>
<DD><A HREF="Tk_Init.htm#M8" NAME="L612"><B>grab</B></A>
<DD><A HREF="Tk_Init.htm#M9" NAME="L613"><B>menu</B></A>
<DD><A HREF="Tk_Init.htm#M10" NAME="L614"><B>selection</B></A>
<DD><A HREF="Tk_Init.htm#M11" NAME="L615"><B>send</B></A>
<DD><A HREF="Tk_Init.htm#M12" NAME="L616"><B>tk</B></A>
<DD><A HREF="Tk_Init.htm#M13" NAME="L617"><B>tkwait</B></A>
<DD><A HREF="Tk_Init.htm#M14" NAME="L618"><B>toplevel</B></A>
<DD><A HREF="Tk_Init.htm#M15" NAME="L619"><B>wm</B></A>
</DL>
<DD><A HREF="Tk_Init.htm#M16" NAME="L620">KEYWORDS</A>
</DL>
<H3><A NAME="M2">NAME</A></H3>
Tk_Init, Tk_SafeInit &mdash; add Tk to an interpreter and make a new Tk application.
<H3><A NAME="M3">SYNOPSIS</A></H3>
<B>#include &lt;tk.h&gt;</B><BR>
int<BR>
<B>Tk_Init</B>(<I>interp</I>)<BR>
int<BR>
<B>Tk_SafeInit</B>(<I>interp</I>)<BR>
<H3><A NAME="M4">ARGUMENTS</A></H3>
<DL class="arguments">
<DT><A HREF="../TclLib/Interp.htm">Tcl_Interp</A> <B>*interp</B> (in)<DD>
Interpreter in which to load Tk.  Tk should not already be loaded
in this interpreter.
<P></DL>
<H3><A NAME="M5">DESCRIPTION</A></H3>
<B>Tk_Init</B> is the package initialization procedure for Tk.
It is normally invoked by the <B><A HREF="../TclLib/AppInit.htm">Tcl_AppInit</A></B> procedure
for an application or by the <B><A HREF="../TclCmd/load.htm">load</A></B> command.
<B>Tk_Init</B> adds all of Tk's commands to <I>interp</I>
and creates a new Tk application, including its main window.
If the initialization is successful <B>Tk_Init</B> returns
<B><A HREF="../TclCmd/catch.htm">TCL_OK</A></B>;  if there is an error it returns <B><A HREF="../TclCmd/catch.htm">TCL_ERROR</A></B>.
<B>Tk_Init</B> also leaves a result or error message
in interpreter <I>interp</I>'s result.
<P>
If there is a variable <B><A HREF="../TclCmd/tclvars.htm">argv</A></B> in <I>interp</I>, <B>Tk_Init</B>
treats the contents of this variable as a list of options for the
new Tk application.
The options may have any of the forms documented for the
<B><A HREF="../UserCmd/wish.htm">wish</A></B> application (in fact, <B><A HREF="../UserCmd/wish.htm">wish</A></B> uses Tk_Init to process
its command-line arguments).
<P>
<B>Tk_SafeInit</B> is identical to <B>Tk_Init</B> except that it removes
all Tk commands that are considered unsafe.  Those commands and the
reasons for their exclusion are:
<P>
<DL class="description">
<DT><A NAME="M6"><B>bell</B></A><DD>
Continuous ringing of the bell is a nuisance.
<P><DT><A NAME="M7"><B>clipboard</B></A><DD>
A malicious script could replace the contents of the clipboard with
the string
&ldquo;<B>rm -r *</B>&rdquo;
and lead to surprises when the contents of the clipboard are pasted.
<P><DT><A NAME="M8"><B>grab</B></A><DD>
Grab can be used to block the user from using any other applications.
<P><DT><A NAME="M9"><B>menu</B></A><DD>
Menus can be used to cover the entire screen and to steal input from
the user.
<P><DT><A NAME="M10"><B>selection</B></A><DD>
See clipboard.
<P><DT><A NAME="M11"><B>send</B></A><DD>
Send can be used to cause unsafe interpreters to execute commands.
<P><DT><A NAME="M12"><B>tk</B></A><DD>
The tk command recreates the send command, which is unsafe.
<P><DT><A NAME="M13"><B>tkwait</B></A><DD>
Tkwait can block the containing process forever
<P><DT><A NAME="M14"><B>toplevel</B></A><DD>
Toplevels can be used to cover the entire screen and to steal input
from the user.
<P><DT><A NAME="M15"><B>wm</B></A><DD>
If toplevels are ever allowed, wm can be used to remove decorations,
move windows around, etc.
<P></DL>
<H3><A NAME="M16">KEYWORDS</A></H3>
<A href="../Keywords/S.htm#safe">safe</A>, <A href="../Keywords/A.htm#application">application</A>, <A href="../Keywords/I.htm#initialization">initialization</A>, <A href="../Keywords/L.htm#load">load</A>, <A href="../Keywords/M.htm#main window">main window</A>
<div class="copy">Copyright &copy; 1995-1996 Sun Microsystems, Inc.
</div>
</BODY></HTML>
